﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace phminarm.algorithm.Base
{
    public class Bear
    {
        public Bear(float d, float D, float B, float H, float r, float alpha, float red, float ren)
        {
            this.d = d;
            this.D = D;
            this.B = B;
            this.H = H;
            this.r = r;
            this.alpha = alpha;
            this.red = red;
            this.ren = ren;
        }
        public float d { get; private set; } //内径
        public float D { get; private set; } //外径
        public float B { get; private set; } //轴承宽度
        public float H { get; private set; } //轴承高度
        public float r { get; private set; } //倒角尺寸
        public float alpha { get; private set; } //接触角

        public float fr { get; private set; }

        //节径
        public float pitchdiameter
        {
            get
            {
                return Convert.ToSingle(0.5 * (d + D) / Math.Cos(alpha));
            }
        }
        public float red { get; private set; }//滚动体直径rolling element diameter
        public float ren { get; private set; }//滚动体数量rolling element number

        public float BPFO { get; private set; }//外圈故障特征频率 ball pass frequency outer race
        public float BPFI { get; private set; }//内圈故障特征频率 ball pass frequency inner race
        public float BSF { get; private set; }//滚动体故障特征频率 Ball/roller spin frequency
        public float FTF { get; private set; }//保持架故障特征频率 Fundamental train frequency/cage speed 

        public float BPFOA;//外圈故障特征频率幅值 
        public float BPFIA;//内圈故障特征频率幅值 
        public float BSFA;//滚动体故障特征频率幅值 
        public float FTFA;//保持架故障特征频率幅值 

        public void GetFeatures(float rpm)
        {
            float fr = rpm / 60;
            this.fr = fr;
            BPFO = Convert.ToSingle(ren * fr / 2 * (1 - red / pitchdiameter * Math.Cos(alpha)));
            BPFI = Convert.ToSingle(ren * fr / 2 * (1 + red / pitchdiameter * Math.Cos(alpha)));
            BSF = Convert.ToSingle(fr / 2 * pitchdiameter / red * (1 - Math.Pow(red / pitchdiameter * Math.Cos(alpha), 2)));
            FTF = Convert.ToSingle(fr / 2 * (1 - red / pitchdiameter * Math.Cos(alpha)));
        }
    }
}
